<script setup>
import { useRouter } from "vue-router";
import { getShouCang } from "@/http/api.js";
import { onMounted, reactive } from "vue";
const router = useRouter();
const data = reactive({
  SClist: [], // 收藏的数据
});
onMounted(() => {
  getShouCList(); //调用收藏的数据
});
// 收藏的数据
const getShouCList = async () => {
  const res = await getShouCang();
  data.SClist = res.list;
  console.log(data.SClist);
};
</script>
<template>
  <div class="shou">
    <header>
      <van-icon name="arrow-left" @click="$router.push('/my')" />
      <h3>我的收藏</h3>
    </header>
    <!-- 列表 -->
    <ul>
      <li
        v-for="(item, index) in data.SClist"
        :key="item.id"
        @click="$router.push(`/goods/${item.id}`)"
      >
        <span class="sp">{{ item.course_classify_title }}</span>
        <p class="p1">{{ item.title }}</p>
        <div class="div1">
          <p
            v-for="(item1, index1) in item.teacher"
            :key="index1"
            class="teacher"
          >
            <img :src="item1.avatar" alt="" />
            <span>{{ item1.teacher_name }}</span>
          </p>
        </div>
        <div class="ren">
          <p>{{ item.sales_num }}人已报名</p>
          <p style="color: red">
            ￥{{ index == 0 ? "免费" : item.price / 100 + ".00" }}
          </p>
        </div>
      </li>
    </ul>
  </div>
</template>
<style lang="scss" scoped>
.shou {
  header {
    height: 88px;
    display: flex;
    align-items: center;
    margin-top: 20px;
    .van-icon {
      width: 60px;
      height: 60px;
      text-align: center;
    }
    h3 {
      flex: 1;
      text-align: center;
      font-size: 36px;
    }
  }
  ul {
    padding: 0 20px;
    margin-top: 150px;
    margin-bottom: 100px;

    li {
      font-size: 32px;
      margin: 30px 0;
      background: #fff;
      border-radius: 20px;
      box-shadow: 0 0.04rem 0.09333rem 0 hsl(0deg 0% 81% / 35%);
      .sp {
        width: 120px;
        font-size: 25px;
        padding: 10px 10px;
        background: orangered;
        color: #fff;
      }
      .p1 {
        margin-left: 20px;
      }
      .div1 {
        display: flex;
        align-items: center;
        margin: 40px 40px;
        .teacher {
          margin: 20px 20px;
        }
        img {
          width: 50px;
          height: 50px;
          vertical-align: middle;
          border-radius: 50%;
        }
        span {
          margin-left: 10px;
          font-size: 20px;
        }
      }
      .ren {
        display: flex;
        justify-content: space-between;
        padding: 0 40px;
      }
    }
  }
}
</style>
